home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cc04.arc / VUE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-03-15  |  1.6 KB  |  90 lines

  1. /* - vue.c hex dump routine - */
  2.  
  3. #include <stdio.h>
  4.  
  5. main(argc,argv)
  6. int argc;
  7. char *argv[];
  8. {
  9.  
  10. FILE *fp,*fopen();
  11.  
  12.     if(argc==1){
  13.       printf("%s","no file specified in command line");
  14.       exit(0);
  15.     }
  16.     while(--argc>0)
  17.       if((fp=fopen(*++argv,"r"))==NULL){
  18.         printf("vue: cannot open %s\n",*argv);
  19.         break;
  20.       }
  21.       else{
  22.         hexdump(fp);
  23.         fclose(fp);
  24.       }
  25. }
  26.  
  27. hexdump(fp)
  28.  
  29. #define high_order 35512
  30. #define low_order  255
  31.  
  32. FILE *fp;
  33. {
  34.     unsigned word,byte[16],count,index;
  35.     long address;
  36.     int dummy,word_bound;
  37.  
  38.     address=0;
  39.     while(address>-1 && address<128000 && word != EOF){
  40.       count=0;
  41.       while(count<256 && word != EOF){
  42.         printf("%6x ",address);
  43.         index=0;
  44.         word_bound=0;
  45.         while(index<16 && word != EOF){
  46.           if((word=getc(fp)) != EOF){
  47.         byte[index]=word & low_order;
  48.         if(byte[index]<16)printf("0%x",byte[index]);
  49.         else
  50.           printf("%x",byte[index]);
  51.           }
  52.           else
  53.         printf("%x",(word&low_order));
  54.           index++;
  55.           word_bound++;
  56.           if(word_bound == 2){
  57.         printf(" ");
  58.         word_bound=0;
  59.           }
  60.         }
  61.         while(index<16){
  62.           printf("  ");
  63.               if((index/2)*2 != index) printf(" " );
  64.           byte[index] = EOF;
  65.           index++;
  66.         }
  67.         printf(" ");
  68.         for(index=0;index<16;){
  69.           if(byte[index]>31 && byte[index]<128)
  70.         printf("%c",byte[index]);
  71.           else
  72.         printf(".");
  73.           index++;
  74.         }
  75.         printf("\n");
  76.         count += 16;
  77.         address += 16;
  78.       }
  79.       if(word != EOF)
  80.         dummy=getc(stdin);
  81.     }
  82. }
  83. 
  84.         }
  85.         printf("\n");
  86.         count += 16;
  87.         address += 16;
  88.       }
  89.       if(word != EOF)
  90.         dummy=getc